#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;


//  Definition for a binary tree node.
struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution {
public:
    int countNodes(TreeNode* root) {
        if (root == NULL) {
            return 0;
        }
        int num_left = countNodes(root->left);
        int num_right = countNodes(root->right);
        return num_left + num_right + 1;
    }
};


//int main() {
//    TreeNode* head = new TreeNode(1);
//    head->left = new TreeNode(2);
//    head->right = new TreeNode(3);
//    head->left->left = new TreeNode(4);
//    head->left->right = new TreeNode(5);
//    head->right->left = new TreeNode(6);
//    Solution S;
//
//    int T = S.countNodes(head);
//    cout << T << endl;
//}

